import Vue from "vue";
import VueRouter from "vue-router";
import Login from "../views/Login.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    redirect: "/login",
  },

  {
    path: "/login",
    name: "Login",
    component: Login,
    meta: {
      title: "jenkis测试",
    },
  },
  {
    path: "/home",
    name: "Home",
    meta: {
      title: "testjenkins",
    },
    component: () => import("../views/Home.vue"),
    children: [
      {
        path: "work",
        name: "work",
        meta: {
          title: "工作台1",
        },
        component: () => import("../views/Work.vue"),
      },
      {
        path: "message",
        name: "message",
        meta: {
          title: "消息1",
        },
        component: () => import("../views/Message.vue"),
      },
      {
        path: "other",
        name: "other",
        meta: {
          title: "消息1",
        },
        component: () => import("../views/Other.vue"),
      },
    ],
  },
];

const router = new VueRouter({
  routes,
});

router.beforeEach((to, from, next) => {
  next();
});

router.afterEach((to, from) => {
  document.title = to.meta.title;
});

export default router;
